def count_highlights(answer, guess):
    # answer和guess都是3x3的大写字母列表
    green = 0  # 绿色高亮单元格的数量
    yellow = 0  # 黄色高亮单元格的数量

    # 循环遍历答案矩阵
    for i in range(3):
        for j in range(3):
            # 检查猜测单元格是否与答案单元格匹配
            if guess[i][j] == answer[i][j]:
                # 增加绿色计数并标记单元格为已处理
                green += 1
                answer[i][j] = "#"
                guess[i][j] = "#"

    # 再次循环遍历答案矩阵
    for i in range(3):
        for j in range(3):
            # 检查答案单元格是否未被处理
            if answer[i][j] != "#":
                # 循环遍历猜测矩阵
                for k in range(3):
                    for l in range(3):
                        # 检查猜测单元格是否未被处理且与答案单元格匹配
                        if guess[k][l] != "#" and guess[k][l] == answer[i][j]:
                            # 增加黄色计数并标记单元格为已处理
                            yellow += 1
                            answer[i][j] = "#"
                            guess[k][l] = "#"
                            # 如果内部循环被打破，则继续外部循环
                            break
                    # 如果内部循环被打破，则继续外部循环
                    else:
                        continue
                    break
    # 返回绿色和黄色计数
    return green, yellow


if __name__ == '__main__':
    g, y = count_highlights(
        [
            ['A', 'B', 'C'],
            ['D', 'E', 'F'],
            ['G', 'H', 'I']
        ],
        [
            ['A', 'B', 'C'],
            ['D', 'E', 'F'],
            ['G', 'H', 'I']
        ]
    )
    print(g)
    print(y)
